<template>
  <div>
    <span v-for="(item, index) in arr" :key="index">
      <input type="checkbox" @click="hPush(index)"> {{ item }}
    </span>
    <ul>
      <li v-for="(item, index) in newArr" :key="index"> {{ item }} </li>
    </ul>
  </div>
</template>

<script>
export default {
  data() {
    return {
      arr: ["科幻", "喜剧", "动漫", "冒险", "科技", "军事", "娱乐", "奇闻"],
      newArr: []
    };
  },

  mounted() {
    
  },

  methods: {
    hPush(num) {
      const i = this.newArr.findIndex(item => item == this.arr[num])
      console.log(this.newArr)
      if (i == -1) {
        this.newArr.push(this.arr[num])
      } else {
        this.newArr.splice(i, 1)
      }
    }
  },
};
</script>

<style lang="less" scoped>

</style>